<?php

namespace App\Providers;

use App\Services\Auth\AuthInterface;
use App\Services\Auth\PasswordAuth;
use App\Services\Auth\SmsAuth;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;

class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        // 'App\Model' => 'App\Policies\ModelPolicy',
    ];

    /**
     * Register any authentication / authorization services.
     *
     * @return void
     */
    public function boot()
    {
        $this->registerPolicies();

        //
    }
    public function register()
    {
        //
        $this->app->bind(AuthInterface::class,function($app){
            //此处可切换记录日志的方式。
            if ($app->login_type ==LOGIN_TYPE_PASSWORD)
                return new PasswordAuth();
            else if ($app->login_type ==LOGIN_TYPE_SMS)
                return new SmsAuth();

        });
    }
}
